<template>
  <div
    class="radio-btn"
    :style="{ display: disabled ? 'flex' : 'none' }"
    v-if="Hooks.radioVisible.value"
  >
    <div
      :class="Hooks.radioChecked.value ? 'active' : ''"
      :style="{
        cursor: disabled ? 'pointer' : 'not-allowed',
      }"
      v-on="{
        click: disabled ? () => Hooks.handleRadioClick(1) : null,
      }"
    >
      阴性
    </div>
    <div
      :class="
        !Hooks.radioChecked.value && Hooks.radioChecked.value !== undefined
          ? 'active'
          : ''
      "
      :style="{
        cursor: route.query.type === 'create' ? 'pointer' : 'not-allowed',
      }"
      v-on="{
        click: route.query.type === 'create' ? () => Hooks.handleRadioClick(2) : null,
      }"
    >
      阳性
    </div>
  </div>
  <div
    class="detail-tool"
    :style="{
      display: route.query.type === 'create' ? 'flex' : 'none',
    }"
  >
    <div
      v-on="{
        click: route.query.type === 'create' ? Hooks.handleMprSave : null,
      }"
      :style="{
        cursor: route.query.type === 'create' ? 'pointer' : 'not-allowed',
        display: type === 'mpr' ? 'block' : 'none',
      }"
    >
      <i class="iconfont icon-baocun"></i>
      <div>保存</div>
    </div>
    <div
      v-on="{
        click: route.query.type === 'create' ? Hooks.handleMarkDesert : null,
      }"
      :style="{
        cursor: route.query.type === 'create' ? 'pointer' : 'not-allowed',
      }"
    >
      <i class="iconfont icon-feipian"></i>
      <div>标记废片</div>
    </div>
    <div
      v-on="{
        click: route.query.type === 'create' ? Hooks.handleSubmit : null,
      }"
      :style="{
        cursor: route.query.type === 'create' ? 'pointer' : 'not-allowed',
      }"
    >
      <i class="iconfont icon-tijiao"></i>
      <div>提交</div>
    </div>
  </div>
  <div
    class="query-tool"
    :style="{
      display:
        route.query.type === 'create'
          ? 'none'
          : route.query.type === 'query' && route.query.dataType === 'once'
          ? 'none'
          : 'flex',
    }"
  >
    <a-button type="primary" class="prev-btn" @click="Hooks.handlePrevClick"
      >上一个</a-button
    >
    <a-button type="primary" class="next-btn" @click="Hooks.handleNextClick"
      >下一个</a-button
    >
  </div>
  <!-- 标记废片弹窗 -->
  <Dialog
    :visible="Hooks.markScrapVisible.value"
    :title="'标记废片'"
    :width="502"
    :maskClosable="false"
    :isForm="true"
    :modalClass="'mark-scrap-dialog'"
    :okText="'提交'"
    @update:visible="Hooks.handleMarkScrapVisible"
  >
    <template v-slot>
      <div class="radio-container">
        <div class="radio-title">请选择该切片标为废片的原因</div>
        <div class="radio-group">
          <a-radio-group v-model="Hooks.scrapValue.value">
            <a-radio
              class="radio-group-item"
              v-for="item in FilmReadRight.scrapList"
              :key="item.value"
              :value="item.value"
              >{{ item.name }}</a-radio
            >
          </a-radio-group>
        </div>
        <div class="other-container">
          <a-textarea
            v-model="Hooks.discardRemark.value"
            :auto-size="{ minRows: 2, maxRows: 2 }"
            :max-length="200"
            placeholder="请输入其他废片原因（选填）"
          ></a-textarea>
        </div>
      </div>
    </template>
  </Dialog>
  <!-- 提交最终结果弹窗 -->
  <a-modal
    :visible="Hooks.submitVisible.value"
    :title="'提交'"
    :width="502"
    :mask-closable="false"
    :modal-class="'submit-dialog'"
    :footer="false"
    @cancel="Hooks.handleCancel"
  >
    <div>
      <div class="sumbit-body">
        <div class="submit-title">确定提交该切片吗？</div>
        <div class="submit-tip">提交后切片将不再修改</div>
      </div>
      <div class="bottom-btn">
        <a-button
          type="primary"
          class="left-btn"
          @click="Hooks.handleSubmitVisible({ status: 'more', flag: false })"
          >提交获取新切片</a-button
        >
        <a-button
          type="primary"
          class="right-btn"
          @click="Hooks.handleSubmitVisible({ status: 'save', flag: false })"
          >提交并关闭</a-button
        >
      </div>
    </div>
  </a-modal>
  <!-- 当前已经没有新切片的弹窗 -->
  <Dialog
    :visible="Hooks.sectionVisible.value"
    :title="'提示'"
    :width="502"
    :maskClosable="false"
    :isForm="true"
    :hideCancel="true"
    :modalClass="'section-dialog'"
    :okText="'确认'"
    @update:visible="Hooks.handleSectionVisible"
  >
    <template v-slot>
      <div>
        <div class="submit-title">
          <i class="iconfont icon-jingshi_" style="color: #ff7d00; font-size: 18px"></i>
          已没有新切片，请确认后退出该标注任务
        </div>
        <!-- <div class="submit-tip">提交后切片将不再修改</div> -->
      </div>
    </template>
  </Dialog>
</template>

<script lang="ts" setup>
import { inject } from "vue";
import { useRoute } from "vue-router";
import Dialog from "@/components/dialog/index.vue";
import useToolBarRight from "./hooks/useToolBarRight";
import { useFilmReadRight } from "@/store";

const route = useRoute();
const provideState = inject("provideState", { getToolBarItem: new Function() });
const Hooks = useToolBarRight(provideState);
const FilmReadRight = useFilmReadRight();
const props = defineProps({
  disabled: {
    type: Boolean,
    default: false,
  },
  type: {
    type: String,
    default: "",
  },
});
</script>

<style lang="less" scoped>
.radio-btn {
  border: 1px solid #8ea7b2;
  border-radius: 2px;
  display: flex;
  margin-right: 8px;
  div {
    width: 40px;
    height: 27px;
    font-weight: 400;
    font-size: 12px;
    line-height: 27px;
    color: #cedee0;
    text-align: center;
    user-select: none;
  }
  div.active {
    background: #074452;
    color: #13fffb;
  }
}
.radio-btn:hover {
  cursor: pointer;
}
.detail-tool {
  font-weight: 400;
  font-size: 12px;
  line-height: 16px;
  color: #cedee0;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  user-select: none;
  padding-left: 8px;
  border-left: 1px solid rgba(255, 255, 255, 0.16);
}
.detail-tool > div {
  text-align: center;
  margin-right: 18px;
}
.detail-tool > div:hover {
  cursor: pointer;
}
.detail-tool > div > i {
  color: #faad14;
  font-size: 30px;
}
.detail-tool > div > div {
  margin-top: 2px;
}
.query-tool {
  padding-left: 20px;
  padding-right: 16px;
  border-left: 1px solid rgba(255, 255, 255, 0.16);
  .prev-btn {
    margin-right: 12px;
  }
}
</style>
<style lang="less">
.mark-scrap-dialog,
.submit-dialog,
.section-dialog {
  background-color: #272727;
  .arco-modal-header {
    height: 64px;
    background-color: #393a3c;
    font-weight: 700;
    font-size: 18px;
    color: #fff;
    border: 0;
    .arco-modal-title,
    .arco-modal-close-btn {
      font-weight: 700;
      font-size: 18px;
      color: #fff;
    }
    .arco-icon-hover:hover::before {
      background-color: #616367;
    }
  }
  .arco-modal-body {
    .radio-title {
      font-weight: 400;
      font-size: 16px;
      color: #fff;
      margin-bottom: 18px;
      text-align: left;
    }
    .radio-group {
      display: flex;
      align-items: center;
      justify-content: flex-start;
      .arco-radio-group {
        display: flex;
        align-items: center;
        justify-content: flex-start;
        flex-wrap: wrap;
        .radio-group-item {
          margin-bottom: 12px;
          .arco-radio-label {
            white-space: nowrap;
          }
        }
      }
      .arco-radio-icon {
        width: 12px;
        height: 12px;
        line-height: 12px;
        border: 1px solid rgba(255, 255, 255, 0.7);
      }
      .arco-radio-icon::after {
        background-color: transparent;
      }
      .arco-radio:hover .arco-radio-icon {
        border-color: #67c9d5;
      }
      .arco-radio:hover .arco-radio-icon-hover::before {
        background-color: transparent;
      }
      .arco-radio-checked .arco-radio-icon {
        border: 1px solid #67c9d5;
        background-color: transparent;
      }
      .arco-radio-checked .arco-radio-icon::after {
        background-color: #67c9d5;
      }
      &-item {
        font-weight: 400;
        font-size: 14px;
        color: #ccc;
        .arco-radio-label {
          color: #ccc;
        }
      }
    }
    .other-container {
      margin: 4px 0 20px;
      width: 100%;
      height: 32px;
      .arco-textarea-wrapper {
        background-color: transparent;
        border: 1px solid rgba(255, 255, 255, 0.7);
        color: #fff;
      }
    }
    .submit-title {
      font-weight: 400;
      font-size: 22px;
      text-align: center;
      color: #fff;
      margin-bottom: 20px;
    }
    .submit-tip {
      font-weight: 400;
      font-size: 14px;
      text-align: center;
      color: #ccc;
    }
    .sumbit-body {
      margin-bottom: 32px;
    }
    .bottom-btn {
      .left-btn {
        margin-right: 18px;
      }
      button {
        width: 128px;
        height: 40px;
        background-color: #448e97;
        border-radius: 4px;
        font-weight: 400;
        font-size: 16px;
        color: #fff;
      }
      .arco-btn-primary:hover,
      .arco-btn-primary[type="button"]:hover {
        background-color: #67c9d5;
      }
    }
  }
  .arco-modal-footer {
    text-align: center;
    border: 0;
    .arco-btn {
      width: 96px;
      height: 40px;
      font-weight: 400;
      font-size: 16px;
      border-radius: 4px;
    }
    .arco-btn-secondary {
      color: rgba(255, 255, 255, 0.7);
      background-color: #353535;
    }
    .arco-btn-primary {
      background-color: #448e97;
      border-color: #448e97;
    }
    .arco-btn-primary:hover,
    .arco-btn-primary[type="button"]:hover {
      background-color: #67c9d5;
      border-color: #67c9d5;
    }
  }
}
.mark-scrap-dialog {
  .arco-modal-body {
    padding: 20px 32px;
  }
  .arco-modal-footer {
    padding: 0 20px 32px;
  }
}
.submit-dialog {
  .arco-modal-footer {
    .arco-btn {
      width: 128px !important;
    }
  }
}
.mark-tool-dropdown {
  .arco-dropdown {
    padding: 1px;
    background-color: #353e44;
    border: 0;
    border-radius: 2px;
    .arco-dropdown-list {
      display: flex;
      flex-wrap: wrap;
      flex-direction: row;
      max-width: 540px;
    }
    .arco-dropdown-option {
      width: 106px;
      height: 26px;
      line-height: 26px;
      font-weight: 400;
      font-size: 12px;
      color: #ccc;
      padding: 0;
      margin: 1px;
      background: #414b52;
      div:nth-of-type(2) {
        white-space: nowrap;
        text-overflow: ellipsis;
        overflow: hidden;
        min-width: 80px;
        width: 80px;
      }
    }
    .drop-item {
      justify-content: flex-start;
      padding-left: 4px;
      .arco-dropdown-option-content {
        display: flex;
        align-items: center;
        justify-content: flex-start;
      }
      &-color {
        width: 10px;
        height: 10px;
        margin-right: 4px;
        margin-top: 2px;
      }
    }
    .arco-dropdown-option-active,
    .arco-dropdown-option:not(.arco-dropdown-option-disabled):hover {
      background: #5c6871;
      text-decoration: none;
      color: #13fffb;
    }
  }
}
.arco-select-dropdown {
  padding: 0;
  border: 0;
  background-color: #42484c;
  .arco-select-option {
    background-color: #42484c;
    color: #fff;
    font-weight: 400;
    font-size: 14px;
  }
  .arco-select-option-active {
    color: #67c9d5;
    font-weight: 400;
    font-size: 14px;
    background-color: #42484c;
  }
  .arco-select-option:not(.arco-select-dropdown .arco-select-option-disabled):hover {
    background-color: #5c6871;
    color: #fff;
  }
}
</style>
